package kRender;

import kGeom.*;
import processing.core.*;


public abstract class kApplet extends PApplet {

	public Camera cam;
	public kSpace space;

	public void setup() {
		space = new kSpace(this);
		//cam = new Camera(this, 120);
		kSetup();
	}

	public void draw() {
		background(128);

		kVec p = new kVec();
		space.append(p);

		kLine xv = new kLine(new kVec(), new kVec(1,0,0), 10);
		space.append(xv);

		kLine yv = new kLine(new kVec(), new kVec(0,1,0), 10);
		space.append(yv);

		kLine zv = new kLine(new kVec(), new kVec(0,0,1), 10);
		space.append(zv);

		kDraw();
		//cam.feed();
		//space.render(this);

	}


	public abstract void kSetup();
	public abstract void kDraw();
	public abstract void kKeyPressed();

	public void keyPressed(){

		if (key == 'e'){
			//TODO: zoom extents
		} else if (key == 'a'){ 
			//TODO: zoom all geometry
		}else {
			kKeyPressed();
		}
	}


	public void mouseDragged() {
		//TODO: cntl+leftclick not working on intel macs

		if ((keyPressed) && (key==CODED)){
			if (keyCode == SHIFT){
				cam.truck((mouseX - pmouseX) / -4.0f);
				cam.boom((mouseY - pmouseY) / -4.0f);
			}else if(keyCode == CONTROL){
				cam.dolly((mouseY - pmouseY) / 1.0f);
			}
		} else{
			cam.tumble(radians(pmouseX - mouseX), radians(pmouseY - mouseY));
		}



	}

}
